//
//  MoveItemController.m
//  BeautyBaoUnion
//
//  Created by 肖智 on 2016/10/26.
//  Copyright © 2016年 肖智. All rights reserved.
//

#import "MoveItemController.h"
@interface MoveItemController (){
    XZTableView *_tableView;
    NSArray *_originData;
    NSArray *_originHeight;
    NSMutableArray *_tempData;
    NSMutableArray *_tempHeight;
}

@end

@implementation MoveItemController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.automaticallyAdjustsScrollViewInsets = NO;
    _tableView = [[XZTableView alloc] initWithFrame:CGRectInset(self.view.bounds, 0, 64) style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.xz_dataSource = self;
    _tableView.rowHeight = 80;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    _originData = @[@"a",@"b",@"c",@"d",@"e",@"f",@"g"];
    _originHeight = @[@(20),@(40),@(60),@(80),@(100),@(120),@(140)];
    _tempData = [NSMutableArray arrayWithArray:_originData];
    _tempHeight = [NSMutableArray arrayWithArray:_originHeight];
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    UIView *v = [[UIView alloc]initWithFrame:CGRectZero];
    _tableView.tableFooterView = v;
    [self.view addSubview:_tableView];
    
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _tempData.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.textLabel.text = [NSString stringWithFormat:@"%ld",indexPath.row];
    cell.textLabel.text = _tempData[indexPath.row];

    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSNumber *height = _tempHeight[indexPath.row];
    return height.floatValue;
}
- (NSMutableArray *)dataSourceForXZTableView:(XZTableView *)tableView{
    return _tempData;
}
- (NSMutableArray *)heightArrayForXZTableView:(XZTableView *)tableView{
    return _tempHeight;
}
- (void)didEndExchangeRow{
    
}
//- (NSArray *)dataSourceArrayInTableView:(JXMovableCellTableView *)tableView
//{
//    return _dataSource.copy;
//}
//
//- (void)tableView:(JXMovableCellTableView *)tableView newDataSourceArrayAfterMove:(NSArray *)newDataSourceArray
//{
//    _dataSource = newDataSourceArray.mutableCopy;
//}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
